home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Message Dialogs / check-sorter.izs < prev    next >
Text File  |  2005-09-28  |  11KB  |  376 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Check Sorter
  4.  
  5. <!/TITLE>
  6.  
  7. <!DESCRIPTION> JavaScript can sort data based on any field of information. In this example, a checkbook register can be sorted by date, check number, check amount, or paid to person. 
  8. <!/DESCRIPTION> 
  9.  
  10. <!CATEGORY>Messages<!/CATEGORY>
  11.  
  12. <!SCRIPT>
  13. <!-- START OF SCRIPT -->
  14.  
  15.  
  16. <!-- HOW TO INSTALL CHECK SORTER:
  17.  
  18.   1.  Copy code into the HEAD section of document
  19.   2.  Put last coding into the BODY section of document  -->
  20.  
  21. <!-- STEP ONE: Add code into HEAD section of document  -->
  22.  
  23. <SCRIPT LANGUAGE="JavaScript">
  24. <!-- Original:  Tom Folkes (tfolkes@cpcug.org) -->
  25.  
  26. <!-- Begin
  27. function dates(datea,dateb){  
  28. var yeara = 1 * datea.substring(6,8);
  29. var yearb = 1 * dateb.substring(6,8);
  30. if (yeara > yearb) return true;
  31. if (yeara < yearb) return false;
  32.  
  33. var montha = 1 * datea.substring(0,2);
  34. var monthb = 1 * dateb.substring(0,2);
  35. if (montha > monthb) return true;
  36. if (montha < monthb) return false;
  37.  
  38. var daya = 1 * datea.substring(3,5);
  39. var dayb = 1 * dateb.substring(3,5);
  40. if (daya > dayb) return true;
  41. return false;
  42. }
  43.  
  44. function exchange(i,form){     
  45. /* This function swaps the information in the various cells */
  46. document.forms[6].check.value = document.forms[i].check.value;
  47. document.forms[i].check.value = document.forms[i+1].check.value;
  48. document.forms[i+1].check.value = document.forms[6].check.value;
  49. document.forms[6].units.value = document.forms[i].units.value;
  50. document.forms[i].units.value = document.forms[i+1].units.value;
  51. document.forms[i+1].units.value = document.forms[6].units.value;  
  52. document.forms[6].amount.value = document.forms[i].amount.value;
  53. document.forms[i].amount.value = document.forms[i+1].amount.value;
  54. document.forms[i+1].amount.value = document.forms[6].amount.value; 
  55. document.forms[6].presented.value = document.forms[i].presented.value;
  56. document.forms[i].presented.value = document.forms[i+1].presented.value;
  57. document.forms[i+1].presented.value = document.forms[6].presented.value; 
  58. }
  59.  
  60. function amountSort(form){
  61. /* orders the table by amount */   
  62. for (var j = 0; j<5; j++){
  63. for(var i=0; i<5; i++){
  64. var l = 1 * i + 1;
  65. if(1 * document.forms[i].amount.value > 1 * document.forms[i+1].amount.value) {   
  66. exchange(i,form);
  67.          }
  68.       }
  69.    }
  70. }
  71.  
  72. function checkSort(form){
  73. /* orders the table by check number */
  74. for (var j = 0; j<5; j++){
  75. for(var i=0; i<5; i++){
  76. var l = 1 * i + 1;
  77. if(1 * document.forms[i].check.value > 1 * document.forms[i+1].check.value){   
  78. exchange(i,form);  
  79.          }
  80.       }
  81.    }
  82. }
  83.  
  84. function dateSort(form){
  85. /* orders the table by date */
  86. for (var j = 0; j<5; j++){
  87. for(var i=0; i<5; i++){
  88. var l = 1 * i + 1;
  89. if(dates(document.forms[i].units.value,document.forms[i+1].units.value)){
  90. exchange(i,form);  
  91.          }
  92.       }
  93.    }
  94. }
  95.  
  96. function presentSort(form){   
  97. /* orders the table by presenter */
  98. for (var j = 0; j<5; j++){    
  99. for(var i=0; i<5; i++){
  100. var l = 1 * i + 1;
  101. if(document.forms[i].presented.value >document.forms[i+1].presented.value){    
  102. exchange(i,form);   
  103.          }
  104.       }
  105.    }
  106. }
  107.  
  108. // End -->
  109. </SCRIPT>
  110. </HEAD>
  111.  
  112. <!-- STEP TWO: Add code into BODY section of document  -->
  113.  
  114. <center>
  115. <table border=4>
  116.  
  117. <form method=post>
  118. <tr>
  119. <td><div align=center> <input type="button" value="DATE" onclick=dateSort(this.form)> </div></td>
  120. <td><div align=center> <input type="button" value="CK #" onClick=checkSort(this.form)> </div></td>
  121. <td><div align=center> <input type="button" value="AMOUNT" onClick=amountSort(this.form)> </div></td>
  122. <td><div align=center> <input type="button" value="PAID TO" onClick=presentSort(this.form)> </div></td>
  123. </tr>
  124. <tr>
  125. <td><input type=text name=units size=8 value=12/07/95></td>
  126. <td><input type=text name=check size=6 value=3></td>
  127. <td><input type=text name=amount size=9 value=99.10></td>
  128. <td><input type=text name=presented size=20 value="Sears"></td>
  129. </tr>
  130. </form>
  131.  
  132. <form method=post>
  133. <tr>
  134. <td><input type=text name=units size=8 value=11/05/95></td>
  135. <td><input type=text name=check size=6 value=7></td>
  136. <td><input type=text name=amount size=9 value=12.01></td>
  137. <td><input type=text name=presented size=20 value="Holiday Inn"></td>
  138. </tr>
  139. </form>
  140.  
  141. <form method=post>
  142. <tr>
  143. <td><input type=text name=units size=8 value=11/03/95></td>
  144. <td><input type=text name=check size=6 value=1></td>
  145. <td><input type=text name=amount size=9 value=1.08></td>
  146. <td><input type=text name=presented size=20 value="McDonalds"></td>
  147. </tr>
  148. </form>
  149.  
  150. <form method=post>
  151. <tr>
  152. <td><input type=text name=units size=8 value=12/01/94></td>
  153. <td><input type=text name=check size=6 value=33></td>
  154. <td><input type=text name=amount size=9 value=22.05></td>
  155. <td><input type=text name=presented size=20 value="IBM"></td>
  156. </tr>
  157. </form>
  158.  
  159. <form method=post>
  160. <tr>
  161. <td><input type=text name=units size=8 value=12/23/95></td>
  162. <td><input type=text name=check size=6 value=22></td>
  163. <td><input type=text name=amount size=9 value=11.95></td>
  164. <td><input type=text name=presented size=20 value="American Airlines"></td>
  165. </tr>
  166. </form>
  167.  
  168. <form method=post>
  169. <tr>
  170. <td><input type=text name=units size=8 value=12/26/95> </td>
  171. <td><input type=text name=check size=6 value=11></td>
  172. <td><input type=text name=amount size=9 value=22.65></td>
  173. <td><input type=text name=presented size=20 value="Disney Land"></td>
  174. </tr>
  175. </form>
  176.  
  177. </table>
  178. </center>
  179.  
  180. <form method=post>
  181. <tr>
  182. <td><input type=hidden name=units size=5></td>
  183. <td><input type=hidden name=check size=6></td>
  184. <td><input type=hidden name=amount size=5></td>
  185. <td><input type=hidden name=presented size=20></td>
  186. <tr>
  187. </form>
  188.  
  189.  
  190. <!-- END OF SCRIPT -->
  191. <!/SCRIPT>
  192.  
  193. <!PREVIEW>
  194. <!-- START OF SCRIPT -->
  195.  
  196.  
  197. <!-- HOW TO INSTALL CHECK SORTER:
  198.  
  199.   1.  Copy code into the HEAD section of document
  200.   2.  Put last coding into the BODY section of document  -->
  201.  
  202. <!-- STEP ONE: Add code into HEAD section of document  -->
  203.  
  204. <SCRIPT LANGUAGE="JavaScript">
  205. <!-- Original:  Tom Folkes (tfolkes@cpcug.org) -->
  206.  
  207. <!-- Begin
  208. function dates(datea,dateb){  
  209. var yeara = 1 * datea.substring(6,8);
  210. var yearb = 1 * dateb.substring(6,8);
  211. if (yeara > yearb) return true;
  212. if (yeara < yearb) return false;
  213.  
  214. var montha = 1 * datea.substring(0,2);
  215. var monthb = 1 * dateb.substring(0,2);
  216. if (montha > monthb) return true;
  217. if (montha < monthb) return false;
  218.  
  219. var daya = 1 * datea.substring(3,5);
  220. var dayb = 1 * dateb.substring(3,5);
  221. if (daya > dayb) return true;
  222. return false;
  223. }
  224.  
  225. function exchange(i,form){     
  226. /* This function swaps the information in the various cells */
  227. document.forms[6].check.value = document.forms[i].check.value;
  228. document.forms[i].check.value = document.forms[i+1].check.value;
  229. document.forms[i+1].check.value = document.forms[6].check.value;
  230. document.forms[6].units.value = document.forms[i].units.value;
  231. document.forms[i].units.value = document.forms[i+1].units.value;
  232. document.forms[i+1].units.value = document.forms[6].units.value;  
  233. document.forms[6].amount.value = document.forms[i].amount.value;
  234. document.forms[i].amount.value = document.forms[i+1].amount.value;
  235. document.forms[i+1].amount.value = document.forms[6].amount.value; 
  236. document.forms[6].presented.value = document.forms[i].presented.value;
  237. document.forms[i].presented.value = document.forms[i+1].presented.value;
  238. document.forms[i+1].presented.value = document.forms[6].presented.value; 
  239. }
  240.  
  241. function amountSort(form){
  242. /* orders the table by amount */   
  243. for (var j = 0; j<5; j++){
  244. for(var i=0; i<5; i++){
  245. var l = 1 * i + 1;
  246. if(1 * document.forms[i].amount.value > 1 * document.forms[i+1].amount.value) {   
  247. exchange(i,form);
  248.          }
  249.       }
  250.    }
  251. }
  252.  
  253. function checkSort(form){
  254. /* orders the table by check number */
  255. for (var j = 0; j<5; j++){
  256. for(var i=0; i<5; i++){
  257. var l = 1 * i + 1;
  258. if(1 * document.forms[i].check.value > 1 * document.forms[i+1].check.value){   
  259. exchange(i,form);  
  260.          }
  261.       }
  262.    }
  263. }
  264.  
  265. function dateSort(form){
  266. /* orders the table by date */
  267. for (var j = 0; j<5; j++){
  268. for(var i=0; i<5; i++){
  269. var l = 1 * i + 1;
  270. if(dates(document.forms[i].units.value,document.forms[i+1].units.value)){
  271. exchange(i,form);  
  272.          }
  273.       }
  274.    }
  275. }
  276.  
  277. function presentSort(form){   
  278. /* orders the table by presenter */
  279. for (var j = 0; j<5; j++){    
  280. for(var i=0; i<5; i++){
  281. var l = 1 * i + 1;
  282. if(document.forms[i].presented.value >document.forms[i+1].presented.value){    
  283. exchange(i,form);   
  284.          }
  285.       }
  286.    }
  287. }
  288.  
  289. // End -->
  290. </SCRIPT>
  291. </HEAD>
  292.  
  293. <!-- STEP TWO: Add code into BODY section of document  -->
  294.  
  295. <center>
  296. <table border=4>
  297.  
  298. <form method=post>
  299. <tr>
  300. <td><div align=center> <input type="button" value="DATE" onclick=dateSort(this.form)> </div></td>
  301. <td><div align=center> <input type="button" value="CK #" onClick=checkSort(this.form)> </div></td>
  302. <td><div align=center> <input type="button" value="AMOUNT" onClick=amountSort(this.form)> </div></td>
  303. <td><div align=center> <input type="button" value="PAID TO" onClick=presentSort(this.form)> </div></td>
  304. </tr>
  305. <tr>
  306. <td><input type=text name=units size=8 value=12/07/95></td>
  307. <td><input type=text name=check size=6 value=3></td>
  308. <td><input type=text name=amount size=9 value=99.10></td>
  309. <td><input type=text name=presented size=20 value="Sears"></td>
  310. </tr>
  311. </form>
  312.  
  313. <form method=post>
  314. <tr>
  315. <td><input type=text name=units size=8 value=11/05/95></td>
  316. <td><input type=text name=check size=6 value=7></td>
  317. <td><input type=text name=amount size=9 value=12.01></td>
  318. <td><input type=text name=presented size=20 value="Holiday Inn"></td>
  319. </tr>
  320. </form>
  321.  
  322. <form method=post>
  323. <tr>
  324. <td><input type=text name=units size=8 value=11/03/95></td>
  325. <td><input type=text name=check size=6 value=1></td>
  326. <td><input type=text name=amount size=9 value=1.08></td>
  327. <td><input type=text name=presented size=20 value="McDonalds"></td>
  328. </tr>
  329. </form>
  330.  
  331. <form method=post>
  332. <tr>
  333. <td><input type=text name=units size=8 value=12/01/94></td>
  334. <td><input type=text name=check size=6 value=33></td>
  335. <td><input type=text name=amount size=9 value=22.05></td>
  336. <td><input type=text name=presented size=20 value="IBM"></td>
  337. </tr>
  338. </form>
  339.  
  340. <form method=post>
  341. <tr>
  342. <td><input type=text name=units size=8 value=12/23/95></td>
  343. <td><input type=text name=check size=6 value=22></td>
  344. <td><input type=text name=amount size=9 value=11.95></td>
  345. <td><input type=text name=presented size=20 value="American Airlines"></td>
  346. </tr>
  347. </form>
  348.  
  349. <form method=post>
  350. <tr>
  351. <td><input type=text name=units size=8 value=12/26/95> </td>
  352. <td><input type=text name=check size=6 value=11></td>
  353. <td><input type=text name=amount size=9 value=22.65></td>
  354. <td><input type=text name=presented size=20 value="Disney Land"></td>
  355. </tr>
  356. </form>
  357.  
  358. </table>
  359. </center>
  360.  
  361. <form method=post>
  362. <tr>
  363. <td><input type=hidden name=units size=5></td>
  364. <td><input type=hidden name=check size=6></td>
  365. <td><input type=hidden name=amount size=5></td>
  366. <td><input type=hidden name=presented size=20></td>
  367. <tr>
  368. </form>
  369.  
  370.  
  371.  
  372. <!-- END OF SCRIPT -->
  373. <!/PREVIEW>
  374.  
  375. <!RELATED>NONE<!/RELATED>
  376.